<template>
  <view>
    <!-- 基础用法 -->
    <SimpleYearSwitcher @change="handleYearChange" />
    
    <!-- 自定义样式 -->
    <SimpleYearSwitcher
      prev-text="⬅"
      next-text="➡"
      :btn-style="{
        color: '#FF6B81'
      }"
      :text-style="{
        fontSize: '40rpx',
        color: '#FF6B81'
      }"
      @change="handleYearChange"
    />
    
    <!-- 通过ref调用方法 -->
    <button @click="$refs.yearSwitcher.resetToCurrent()">回到今年</button>
    <SimpleYearSwitcher ref="yearSwitcher" />
  </view>
</template>

<script>
import SimpleYearSwitcher from '@/components/SimpleYearSwitcher.vue'

export default {
  components: { SimpleYearSwitcher },
  methods: {
    handleYearChange(data) {
      console.log('当前年份:', data.year)
      uni.showToast({
        title: `已切换到 ${data.year}年`,
        icon: 'none'
      })
    }
  }
}
</script>